
    if [ ! -f "/etc/hosts.bak" ]; then
       cp "/etc/hosts"  "/etc/hosts.bak"
    fi


while :
do
   curl -w %{http_code} -s -o curl-content.txt  http://host-ip/api/dockers-for-hosts > curl-result.txt
   result=`(cat curl-result.txt | grep 200)`

   if [ "$result" !=  "200" ]; then
       echo "====================================="
       echo "`date '+%Y-%m-%d %H:%M:%S'` 请求 http://host-ip/api/dockers-for-hosts 出现错误！ $result"
       echo "====================================="
       sleep 30
   else
      cat /etc/hosts.bak  > /etc/hosts
      echo >> /etc/hosts  ;  echo >> /etc/hosts
      cat curl-content.txt >> /etc/hosts
      echo >> /etc/hosts
      echo  "# `date '+%Y-%m-%d %H:%M:%S'`" >> /etc/hosts
      sleep 15
   fi
done
